let app = getApp();
Page({
  data: {
    openid:'',
    bumenmingcheng:'',
    salesmanName:'',
    kehuName:'',
    userInfo:[],
    iconFlag: false,
  },
  onShow(){
    let that = this;
   
  },
  onLoad (options) {
    let that = this;
    wx.getStorage({
      key: 'bumenmingcheng',
      success(res) {        
        that.setData({
          bumenmingcheng: res.data
        });
        wx.getStorage({
          key: 'openid',
          success(res) {
            that.setData({
              openid: res.data
            });
            that.loadList();
          },
        })  
      },
    })     
  },
  loadList() {
    let that = this;
    app.get('YeWuYuankeHu', {
      action: 'getxiajikehubyopenid',
      openid: that.data.openid,
      BuMenMingCheng: that.data.bumenmingcheng,
      YeWuYuanXingMing: that.data.salesmanName,
      KeHuXingMing: that.data.kehuName
    }).then((res) => {      
      that.setData({
        userInfo: res
      });
      if (res.length === 0) {
        app.toast('未查找到数据');
      }
    })
  },
  jumpClient(e){    
    wx.navigateTo({
      url: '/pages/salesmanOrderDetail/salesmanOrderDetail?id=' + e.currentTarget.id,
    })
  },
  inquireBtn() {
    let flag = '';
    flag = !this.data.iconFlag;
    this.setData({
      iconFlag: flag
    })
  },
  formReset() {
    this.setData({
      startTime: '',
      endTime: ''
    });
    app.toast('搜索条件已重置');
  },
  formSubmit(e) {
    let formData = e.detail.value,
      salesmanName = formData.salesmanName,
      kehuName = formData.kehuName;
      this.setData({
        salesmanName: formData.salesmanName,
        kehuName: formData.kehuName
      });
    this.loadList();
  },
})